package com.framework.spring.lifeCycle.lc.bean;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Slf4j(topic = "e")
@Component
public class A implements BeanNameAware, ApplicationContextAware, InitializingBean {

	public A() {
		log.info("A construct");
	}

	@Autowired
	B field;

	C c;

	public void m0() {
		log.info("A#m0");
	}

	public void setC(C c) {
		log.info("3 bytype wired:{}", c);
		this.c = c;
	}

	@PostConstruct
	public void init() {
		log.info("6 A#postconstruct init");
	}

	@Override
	public void setBeanName(String name) {
		log.info("4 A#BeanNameAware.setBeanName:{}", name);
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		log.info("7 A#InitializingBean.afterPropertiesSet");
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		log.info("5 A#ApplicationContextAware.setApplicationContext:{}", applicationContext);
	}
}
